package me.jayramafisher.mcsurvival;

import java.util.Map;
import java.util.TreeMap;

//File: CommandPreparer.java
//Description: stores a map of each players prepared command.
//Last date of modification (yyyymmdd): 20110716

/**
*The CommandPreparer class is a wrapper for a map that stores what command each player has prepared.
*/

public class CommandPreparer
{

    private Map<String,String> prepared_commands;

    public CommandPreparer()
    {
        prepared_commands = new TreeMap<String,String>();
    }

    public void prepareCommand(String player, String command)
    {
        prepared_commands.put(player,command);
    }

    public String getPreparedCommand(String player)
    {
        return prepared_commands.containsKey(player) ? prepared_commands.get(player) : "";
    }

    /**
    *Removes a player from the command map. This should be called after the command is carried out or when the player types /cancel.
    */

    public void clear(String player)
    {
        if(prepared_commands.containsKey(player)) prepared_commands.remove(player);
    }

}
